<%@ page language="java" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!doctype html>
<html lang="en">

<head>
<title>Home</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- VENDOR CSS -->
<link rel="stylesheet"
	href="assets/vendor/bootstrap/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet"
	href="assets/vendor/bootstrap/css/bootstrap-table.min.css">
<link rel="stylesheet"
	href="assets/vendor/bootstrap/css/bootstrap-table.css">
<link rel="stylesheet"
	href="assets/vendor/bootstrap/css/bootstrap.min.css">

<link rel="stylesheet"
	href="assets/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/vendor/linearicons/style.css">
<link rel="stylesheet"
	href="assets/vendor/chartist/css/chartist-custom.css">
<!-- MAIN CSS -->
<link rel="stylesheet" href="assets/css/main.css">
<!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
<link rel="stylesheet" href="assets/css/demo.css">
<!-- GOOGLE FONTS -->
<link
	href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700"
	rel="stylesheet">
<!-- ICONS -->
<link rel="apple-touch-icon" sizes="76x76"
	href="assets/img/apple-icon.png">
<link rel="icon" type="image/png" sizes="96x96"
	href="assets/img/favicon.png">
</head>

<body>

	<jsp:include page="/assets/jsp/header.jsp" flush="true" />
	<jsp:include page="/assets/jsp/menu.jsp" flush="true" />
	<!-- MAIN -->
	<div class="main">
		<!-- MAIN CONTENT -->
		<form role="form" id="searchForm" class="form-horizontal"
			style="border: 1px solid #006600">
			<legend></legend>
			<fieldset>
				<div class="form-group">
					<label class="col-sm-2" for="number">机构号</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" id="number" name="number"
							style="border: 1px solid #006600">
					</div>
					<label class="col-sm-2" for="senior_super">营业上级</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" id="senior_super"
							name="senior_super" style="border: 1px solid #006600">
					</div>
					<label class="col-sm-2" for="accounting_super">帐务上级</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" id="accounting_super"
							name="accounting_super" style="border: 1px solid #006600">
					</div>

				</div>
				<div class="form-group">
					<label class="col-sm-2" for="teller_status">机构级别</label>
					<div class="col-sm-2">
						<select id="teller_status" name="teller_status"
							class="form-control">
							<option value="">请选择</option>
							<option value="0">总行</option>
							<option value="1">分行</option>
							<option value="2">支行</option>
						</select>
					</div>
					<div>
						<label class="col-sm-2" for="teller_status">机构状态</label>
						<div class="col-sm-2">
							<select id="teller_status" name="teller_status"
								class="form-control">
								<option value="">请选择</option>
								<option value="0">已退出</option>
								<option value="1">已登录</option>
								<option value="2">状态异常</option>
							</select>
						</div>
					</div>
				</div>
			</fieldset>
			<div class="form-group">
				<div class="col-sm-1">
					<input type="button" id="searchBtn" class="btn btn-default"
						value="开始搜索" />
				</div>
				<div class="col-sm-1">
					<input type="button" onclick="addOrganizationView();"
						class="btn btn-default" value="添加机构" />
				</div>
			</div>
		</form>
		<legend></legend>
		<table id="table" data-filter-control="true"></table>
	</div>
	<!--列表展示-->

	<!-- END MAIN CONTENT -->
	<!-- END MAIN -->
	<div class="clearfix">
		<footer>
			<div class="container-fluid">
				<p class="copyright">Copyright &copy; 2018.Company ShanChuanli
					All rights reserved.More Templates</p>
			</div>
		</footer>
	</div>
	<!-- END WRAPPER -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width: 600px;">
			<div class="modal-content">
				<div class="modal-header">
					<label>修改机构信息</label>
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
				</div>
				<form role="form" id="change_form" class="form-horizontal"
					style="border-right: 40px solid #FFF; border-top: 10px solid #FFF">
					<div class="form-group">
						<label class="col-sm-3" for="change_number"
							style="font-size: 15px; text-align: right;">机构号</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="change_number"
								name="number" readonly="readonly" />
						</div>
						<label class="col-sm-3" for="change_name"
							style="font-size: 15px; text-align: right;">机构名称</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="change_name"
								name="name">
						</div>

					</div>
					<div class="form-group">
						<label class="col-sm-3" for="change_senior_super"
							style="font-size: 15px; text-align: right;">营业上级</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="change_senior_super"
								name="senior_super" readonly="readonly" />
						</div>
						<label class="col-sm-3" for="change_accounting_super"
							style="font-size: 15px; text-align: right;">管理上级</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="change_accounting_super"
								name="accounting_super" readonly="readonly" >
						</div>

					</div>
					<div class="form-group">
						<label class="col-sm-3" for="change_level"
							style="font-size: 15px; text-align: right;">机构级别</label>
						<div class="col-sm-3">
							<select id="change_level" name="level"
								class="form-control" readonly="readonly" >
								<option value="">请选择</option>
								<option value="0">总行</option>
								<option value="1">分行</option>
								<option value="2">支行</option>
							</select>
						</div>
							<label class="col-sm-3" for="change_workdate"
							style="font-size: 15px; text-align: right;">当前工作日期</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="change_workdate"
								name="workdate"  />
						</div>

					</div>
					<div class="form-group">
					
						<label class="col-sm-3" for="change_adress_code"
							style="font-size: 15px; text-align: right;">机构城市代码</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="change_adress_code"
								name="adress_code">
						</div>
							<label class="col-sm-3" for="change_status"
							style="font-size: 15px; text-align: right;">机构状态</label>
						<div class="col-sm-3">
							<select id="change_status" name="status" class="form-control" readonly="readonly" >
								<option value="">请选择</option>
								<option value="0">已退出</option>
								<option value="1">已登录</option>
								<option value="2">状态异常</option>
							</select>
						</div>
						
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="button" class="btn btn-primary"
							onclick="change_submit();">提交更改</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="modal fade" id="myModal1" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel1" aria-hidden="true">
		<div class="modal-dialog" style="width: 600px;">
			<div class="modal-content">
				<div class="modal-header">
					<label> 新增机构信息</label>
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
				</div>
				<form role="form" id="add_form" class="form-horizontal"
					style="border-right: 40px solid #FFF; border-top: 10px solid #FFF">
					<div class="form-group">
						<label class="col-sm-3" for="add__number"
							style="font-size: 15px; text-align: right;">机构号</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="add_number"
								name="number"  />
						</div>
						<label class="col-sm-3" for="add_name"
							style="font-size: 15px; text-align: right;">机构名称</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="add_name" name="name">
						</div>

					</div>
					<div class="form-group">
						<label class="col-sm-3" for="add_senior_super"
							style="font-size: 15px; text-align: right;">营业上级</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="add_senior_super"
								name="senior_super"  />
						</div>
						<label class="col-sm-3" for="add_accounting_super"
							style="font-size: 15px; text-align: right;">管理上级</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="add_accounting_super"
								name="accounting_super">
						</div>

					</div>
					<div class="form-group">
						<label class="col-sm-3" for="add_level"
							style="font-size: 15px; text-align: right;">机构级别</label>
						<div class="col-sm-3">
							<select id="add_level" name="level" class="form-control">
								<option value="">请选择</option>
								<option value="0">总行</option>
								<option value="1">分行</option>
								<option value="2">支行</option>
							</select>
						</div>
						<label class="col-sm-3" for="add_workdate"
							style="font-size: 15px; text-align: right;">当前工作日期</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="add_workdate"
								name="workdate"  />
						</div>

					</div>
					<div class="form-group">
						
						<label class="col-sm-3" for="add_adress_code"
							style="font-size: 15px; text-align: right;">机构城市代码</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" id="add_adress_code"
								name="adress_code">
						</div>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="button" class="btn btn-primary"
							onclick="addOrganizationSubmit();">提交更改</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<!-- Javascript -->
	<script src="assets/vendor/jquery/jquery.min.js"></script>
	<script src="assets/vendor/bootstrap/js/bootstrap.min.js"></script>
	<script src="assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js"></script>
	<script
		src="assets/vendor/jquery.easy-pie-chart/jquery.easypiechart.min.js"></script>
	<script src="assets/vendor/chartist/js/chartist.min.js"></script>
	<script src="assets/scripts/klorofil-common.js"></script>
	<script src="assets/scripts/common.js"></script>
	<script src="assets/scripts/common.js"></script>
	<script src="assets/scripts/bootstrap-datetimepicker.min.js"></script>
	<script src="assets/scripts/bootstrap-table.js"></script>
	<script src="assets/scripts/bootstrap-table-toolbar.js"></script>

	<script type="text/javascript">
		$("#subPages4").addClass("in");
		$(function() {
			//1.初始化Table
			var oTable = new TableInit();
			oTable.Init();
			//当点击查询按钮的时候执行
			$("#searchBtn").bind("click", oTable.Init);
		});
		var TableInit = function() {
			var oTableInit = new Object();
			//初始化Table
			oTableInit.Init = function() {
				$("#table").bootstrapTable('destroy');
				$('#table').bootstrapTable({
					url : '/chuan/getOrganizationList.do', //请求后台的URL（*）
					method : 'post', //请求方式（*）
					dataField : "data",
					striped : true, //是否显示行间隔色
					cache : false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
					pagination : true, //是否显示分页（*）
					sortable : false, //是否启用排序
					sortOrder : "asc", //排序方式
					queryParams : oTableInit.queryParams,//传递参数（*）
					sidePagination : "server", //分页方式：client客户端分页，server服务端分页（*）
					pageNumber : 1, //初始化加载第一页，默认第一页
					pageSize : 10, //每页的记录行数（*）
					pageList : [ 10, 25 ], //可供选择的每页的行数（*）
					strictSearch : true,
					minimumCountColumns : 2, //最少允许的列数
					clickToSelect : true, //是否启用点击选中行
					height : 500, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
					uniqueId : "number", //每一行的唯一标识，一般为主键列
					cardView : false, //是否显示详细视图
					detailView : false, //是否显示父子表
					columns : [ {
						field : 'number',
						title : '机构代号',
						align : 'center' // 居中显示
					}, {
						field : 'name',
						title : '机构名称',
						align : 'center' // 居中显示
					}, {
						field : 'seniorSuper',
						title : '营业上级',
						align : 'center' // 居中显示
					}, {
						field : 'accountingSuper',
						title : '帐务上级',
						align : 'center' // 居中显示
					}, {
						field : 'level',
						title : '机构级别',
						align : 'center',// 居中显示
						formatter : function(value, row, index) {
							var levelName = "";
							if (value == "0")
								levelName = "总行";
							else if (value == "1")
								levelName = "分行";
							else
								levelName = "状态异常";
							return levelName;
						},
						footerFormatter : "机构级别"
					}, {
						field : 'workdate',
						title : '工作日期',
						align : 'center' // 居中显示
					}, {
						field : 'status',
						formatter : function(value, row, index) {
							var status_name = "";
							if (value == "0")
								status_name = "已退出";
							else if (value == "1")
								status_name = "已登录";
							else if (value == "03")
								status_name = "异常";

							return status_name;
						},
						title : '机构状态',
						align : 'center' // 居中显示
					}, {
						field : 'adressCode',
						title : '城市代码',
						align : 'center' // 居中显示
					}, {
						field : 'Button',
						title : '操作',
						events : operateEvents,
						formatter : operateFormatter
					} ]
				});
			};
			//得到查询的参数
			oTableInit.queryParams = function(params) {
				var temp = { //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
					limit : params.limit, //页面大小
					offset : params.offset, //页码
					number : $("#number").val(),
					senior_super : $("#senior_super").val(),
					accounting_super : $("#accounting_super").val(),
					level : $("#level").val(),
					status : $("#status").val()
				};
				return temp;
			};
			return oTableInit;
		};
		window.operateEvents = {

			"click #tableEditor" : function(e, value, row, index) {
				$("#change_number").val(row.number);
				$("#change_senior_super").val(row.seniorSuper);
				$("#change_accounting_super").val(row.accountingSuper);
				$("#change_name").val(row.name);
				$("#change_level").val(row.level);
				$("#change_workdate").val(row.workdate);
				$("#change_adress_code").val(row.adressCode);
				$("#change_status").val(row.status);
				$('#myModal').modal('show');
			}
		};

		function operateFormatter(value, row, index) {
			return [
					'<button id="tableEditor" type="button" class="RoleOfA btn-default bt-select">编辑</button>' ]
					.join('');
		}

		function change_submit() {
			var data = new Object();
			data.number = $("#change_number").val();
			data.senior_super = $("#change_senior_super").val();
			data.accounting_super = $("#change_accounting_super").val();
			data.name = $("#change_name").val();
			data.level = $("#change_level").val();
			data.workdate = $("#change_workdate").val();
			data.adress_code = $("#change_adress_code").val();
			data.status = $("#change_status").val();
			$.ajax({
				type : "POST",//方法类型
				dataType : "json",//预期服务器返回的数据类型
				url : "/chuan/updateOrganization.do",//url
				contentType : "application/json",
				data : JSON.stringify(data),
				success : function() {
					$.MsgBox.Confirm("温馨提示", "机构信息修改成功", function() {
						$('#myModal').modal('hide');
						location.reload();
					});
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("执行失败");
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		}

		function addOrganizationView() {
			$('#myModal1').modal('show');
		}
		function addOrganizationSubmit() {
			var data = new Object();
			data.number = $("#add_number").val();
			data.senior_super = $("#add_senior_super").val();
			data.accounting_super = $("#add_accounting_super").val();
			data.name = $("#add_name").val();
			data.level = $("#add_level").val();
			data.workdate = $("#add_workdate").val();
			data.adress_code = $("#add_adress_code").val();
			$.ajax({
				type : "POST",//方法类型
				dataType : "json",//预期服务器返回的数据类型
				url : "/chuan/addOrganization.do",//url
				contentType : "application/json",
				data : JSON.stringify(data),
				success : function() {
					$.MsgBox.Confirm("温馨提示", "柜员信息修改成功", function() {
						$('#myModal').modal('hide');
						location.reload();
					});
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("执行失败");
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		}
	</script>

</body>

</html>
